package com.lizhen.core.function.dns;

import java.net.InetAddress;

/**
 * @author lizhen
 */
public class DNS {
    public static void main(String[] args) {
        DNS dns = new DNS();
        dns.getAllDNS();
        dns.getDNS();
    }

    private void getAllDNS() {
        try {
            InetAddress[] address = InetAddress.getAllByName("www.google.com");

            for (int i = 0; i < address.length; i++) {
                System.out.println(address[i].getHostAddress());
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    private void getDNS() {
        try {
            InetAddress address = InetAddress.getByName("mdm.zte.com.cn");

            System.out.println(address.getHostAddress());
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
